#include <iostream>
using namespace std;
#include <fstream>
#include <istream>

int main()
{
    ifstream ifile("i.txt", ios::in); //只能拿来输入 重载 >>
    if (!ifile)
        cout << "open error i" << endl;
    char buf[1024];
    if (ifile >> buf)
        cout << buf << endl;

    ofstream ofile("o.txt", ios::out | ios::app); //重载 << ---- ios::trunc 每次清除之后再写入
    if (!ofile)
        cout << "open error o" << endl;
    ofile << "add one apple" << endl; //输出到文件中

    return 0;
}